/**
 * 
 */
package com.google.code.jam;

import com.google.code.jam.util.FileHelper;

/**
 * @author spaida
 *
 */
public class OutputService 
{
	String outFileName;
	StringBuilder strBuilder=new StringBuilder();
	int i=1;
	
	public OutputService(String outFileName) 
	{
		this.outFileName=outFileName;
	}

	public void insertCaseResult(boolean redWin, boolean blueWin)
	{
		strBuilder.append("Case #");
		strBuilder.append(i++);
		strBuilder.append(": ");
		
		if(redWin && blueWin)
			strBuilder.append("Both");
		else if(redWin)
			strBuilder.append("Red");
		else if(blueWin)
			strBuilder.append("Blue");
		else
			strBuilder.append("Neither");
		
		strBuilder.append("\n");
	}
	
	public void writeResultInFile(String fileName) throws Exception
	{
		System.out.println(strBuilder.toString());
		FileHelper.writeFile(fileName, strBuilder.toString());
	}
}
